package com.umpay.privi.dao.on.sys.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import com.umpay.common.persist.AbstractDao;
import com.umpay.common.persist.ibatis.DataAccessException;
import com.umpay.common.persist.ibatis.exception.SQLErrorCodeSQLExceptionTranslator;
import com.umpay.privi.dao.EntityDaoImpl;
import com.umpay.privi.dao.on.sys.PrivilegeDao;
import com.umpay.privi.model.sys.Privilege;

/** 
 * desc:权限Dao实现类
 * <p>创建人：Ding Zhe 创建日期：Apr 19, 2013 </p>
 * @version V1.0  
 */
@SuppressWarnings("unchecked")
public class PrivilegeDaoImpl extends EntityDaoImpl<Privilege> implements PrivilegeDao {

	/* 
	 * desc:
	 * (non-Javadoc)
	 * @see com.umpay.pm.dao.on.sys.PrivilegeDao#get(java.lang.Integer)
	 */
	public Privilege get(Integer privilegeId) throws DataAccessException {
		try {
			return (Privilege)getSqlMapClientTemplate().getSqlMapClient().queryForObject("Privilege.Get", privilegeId);
		} catch (SQLException e) {
			throw new SQLErrorCodeSQLExceptionTranslator(AbstractDao.DB_TYPE_DB2).translate(e.getMessage(), e);
		}
	}

	public List<Privilege> findList(Map<String, Object> qryMap)
			throws DataAccessException {
		try {
			return getSqlMapClientTemplate().getSqlMapClient().queryForList("Privilege.Find", qryMap);
		} catch (SQLException e) {
			throw new SQLErrorCodeSQLExceptionTranslator(AbstractDao.DB_TYPE_DB2).translate(e.getMessage(), e);
		}
	}

	public List<Privilege> findListByRoleId(Map<String, Object> qryMap)
			throws DataAccessException {
		try {
			return getSqlMapClientTemplate().getSqlMapClient().queryForList("Privilege.FindByRoleId", qryMap);
		} catch (SQLException e) {
			throw new SQLErrorCodeSQLExceptionTranslator(AbstractDao.DB_TYPE_DB2).translate(e.getMessage(), e);
		}
	}
	public List<Privilege> findListByRoleIdList(Map<String, Object> qryMap)
			throws DataAccessException {
		try {
			return getSqlMapClientTemplate().getSqlMapClient().queryForList("Privilege.FindByRoleIdList", qryMap);
		} catch (SQLException e) {
			throw new SQLErrorCodeSQLExceptionTranslator(
					AbstractDao.DB_TYPE_DB2).translate(e.getMessage(), e);
		}
	}
	
}



